Embed Code Examples

The Embed Code Snippet generator dialog generates embedded content snippets that you can then copy into your script editor. The embed code dialog generates code snippets in JavaScript, React, Angular, and Raw JavaScript.

Within the admin console, there is a matching Embed Hub Code Snippet generator that performs a similar function for embedding hubs.

  • Click here to learn more about the Embed Code dialog.
  • Click here to learn how to print embedded content.

Access the Embed Code Dialog

The Embed Code dialog is opened directly from the item being embedded; it can be opened from the content items Actions Panel or App tab menu.

First, the user should select the required language: JavaScript, React, Angular, or Raw JavaScript (blue highlight below).

Instructions will be displayed above each code snippet in the code window (red highlight below). These instructions indicate any steps you need to take before running the embed snippet. When using JavaScript (without full HTML), React, or Angular, you must install the NPM embed API in your development project prior to running the embed snippet.

  • Click here to learn how to install the embed API.

Note: The tabs, options, and buttons seen in the preceding image are described in full in the topic Embed Snippet Generator.

Code Snippet Examples

Embed Multiple Items

If embedding multiple items on the same page, the embed script must be adjusted accordingly, to include multiple embed containers and content IDs.

Authentication Examples

A significant aspect of embedding is the authentication process. The Embed API library exposes several authentication methods to simplify this experience when authenticating from the JavaScript client. However, there are techniques for authenticating from the server-side of a web application as well. In either case, they are using Pyramid REST API framework to generate a security token to access the embedding client.

  • Click here for more on authentication examples for embedding.